<?php
include_once "settings.php";
include_once "lang.php";

echo <<<HTML_HEADER
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>IBDB - Full</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="main.css">

</head>
<body>
HTML_HEADER;

//echo $_GET["bookID"];

printSearchBox();


$code = file_get_contents("http://localhost:8983/solr/collection1/select?&wt=php&q=bookID:".$_GET["bookID"]);
eval("\$result = " . $code . ";");


foreach ($result["response"]['docs'][0]["authorFullName"] as $currentAuthorName)
{
	$authorLink = "<a href='index.php?searchTerm=*&fq=authorFullName:\"".addslashes($currentAuthorName).
	"\"&start=0&rows=10'>" .$currentAuthorName. "</a> <br>" ;

}

$seqList = "";
		if (isset($result["response"]['docs'][0]["sequenceFull"]))
		{
			foreach ($result["response"]['docs'][0]["sequenceFull"] as $currentSequence)
			{
				$sequenceTmp = explode("#", $currentSequence);
				$seq = "<a href='index.php?searchTerm=*&fq=sequenceFull:\"".addslashes($sequenceTmp[0])."\"&start=0&rows=10'>" .$sequenceTmp[0]. "</a>" ;

				$seqList = $seqList . "(" . $seq ." - ". $sequenceTmp[1] . ") </a>";
			}
		}

$lang = $langList[$result["response"]['docs'][0]['lang'][0]] ;
$srcLang  =  (isset($langList[$result["response"]['docs'][0]['srcLang'][0]]) ?  $langList[$result["response"]['docs'][0]['srcLang'][0]] : "");


$image = $COVER_DIR.$result["response"]['docs'][0]['coverFileName'][0] ;

$linkToFile = "<a href='" .
		$BOOK_DIR . mb_substr($result["response"]['docs'][0]['fileName'][0],0,2).
		"/".
		$result["response"]['docs'][0]['fileName'][0].
		"'>".
		$result["response"]['docs'][0]['fileName'][0].
		"</a>" ;

echo <<<DISPLAY_BOOK
<table cellpadding="0" cellspacing="0" class="fullViewTable" style="width: 960px">
	<tr>
		<td class="coverTD" rowspan="13"><img class='coverImg' width='240px' src='{$image}'></td>
	</tr>
	<tr>
		<td class="titleTD">{$result["response"]['docs'][0]['title'][0]}</td>
	</tr>
	<tr>
		<td class="authorTD"><p class="trascript">Автор: </p>$authorLink</td>
	</tr>
	<tr>
		<td class="seqTD"><p class="trascript">Серия: </p>{$seqList}</td>
	</tr>
	<tr>
		<td><p class="trascript">Язык: </p>{$lang} <br><p class="trascript">Язык оригинала: </p> {$srcLang}</td>
	</tr>
	<tr>
		<td><p class="trascript">Аннотация: </p>{$result["response"]['docs'][0]['annotation'][0]}</td>
	</tr>
	<tr>
		<td><p class="trascript">Ключевые слова: </p>{$result["response"]['docs'][0]['keywords'][0]}</td>
	</tr>
	<tr>
		<td><p class="trascript">Данные издательства: </p>
			<ul class="publisherInfoList">
				 <li> {$result["response"]['docs'][0]['publisherBookName'][0]} </li>
				 <li> {$result["response"]['docs'][0]['publisherPublisher'][0]} </li>
				 <li> {$result["response"]['docs'][0]['publisherCity'][0]} </li>
				 <li> {$result["response"]['docs'][0]['publisherYear'][0]} </li>
 				 <li> {$result["response"]['docs'][0]['publisherISBN'][0]} </li>
			</ul>
		</td>
	</tr>
	<tr>
		<td><p class="trascript">Формат: </p>{$result["response"]['docs'][0]['fileType'][0]}</td>
	</tr>
	<tr>
		<td><p class="trascript">Линк на flibusta: </p> <a href='http://flibusta.net/b/{$result["response"]['docs'][0]['flibustaBookID'][0]}'>{$result["response"]['docs'][0]['flibustaBookID'][0]}</a></td>
	</tr>
	<tr>
		<td><p class="trascript">Имя файла (размер в байтах): </p> {$linkToFile} ({$result["response"]['docs'][0]['fileSize'][0]})</td>

	</tr>
	<tr>
		<td><p class="trascript">id (ф.id): </p>{$result["response"]['docs'][0]['bookID'][0]} ({$result["response"]['docs'][0]['flibustaBookID'][0]})</td>
	</tr>
	<tr>
		<td><p class="trascript">reserved: </p>10</td>
	</tr>
	<tr>
		<td><p class="trascript">reserved: </p>11</td>
	</tr>
</table>
DISPLAY_BOOK;


echo <<<HTML_FOOTER
</body>
</html>
HTML_FOOTER;

?>
